#pragma once

#include "includes.h"

class Piece
{
private:
	float x, y, z;
	char playerChar;
	float base;
	float height;
	GLUquadric* cylinder;
	GLUquadric* side;
public:
	Piece() 
	{
		cylinder = gluNewQuadric();
		side = gluNewQuadric();
	}

	Piece(float _x, float _y, float _z, char _player, float sizeOfTile)
	{
		cylinder = gluNewQuadric();
		side = gluNewQuadric();
		x = _x;
		y = _y;
		z = _z;
		base = 3.0*sizeOfTile/8.0;
		height = base/4.0;
		playerChar = _player;
	}

	void setX(float _x)
	{
		x=_x;
	}

	float getX()
	{
		return x;
	}

	void setY(float _y)
	{
		y=_y;
	}

	void setZ(float _z)
	{
		z = _z;
	}

	float getY()
	{
		return y;
	}

	float getZ()
	{
		return z;
	}

	void setHeight(float _height)
	{
		height = _height;
	}

	float getHeight()
	{
		return height;
	}

	void setPlayerChar(char _p)
	{
		playerChar = _p;
	}

	char getPlayerChar()
	{
		return playerChar;
	}

	void renderPiece()
	{
		glPushMatrix();
			glRotatef(90.0,1.0,0.0,0.0);
			gluCylinder(cylinder, base, base, height, 20, 20);
		glPopMatrix();

		glPushMatrix();
			glTranslatef(0.0, -height, 0.0);
			glRotatef(90.0,1.0,0.0,0.0);
			gluDisk(cylinder, 0, base, 20, 3);
		glPopMatrix();

		glPushMatrix();
			glRotatef(-90.0,1.0,0.0,0.0);
			gluDisk(cylinder, 0, base, 20, 3);			
		glPopMatrix();
	}

	void render()
	{
		if(playerChar == 'a')
		{
			glEnable(GL_TEXTURE_2D);
			gluQuadricNormals(cylinder, GLU_SMOOTH);
			glBindTexture(GL_TEXTURE_2D, 2005);
			gluQuadricTexture(cylinder, GL_TRUE);
			glPushMatrix();
				glTranslatef(x, y, z);
				renderPiece();
			glPopMatrix();  
			glDisable(GL_TEXTURE_2D);
		}
		else
		{
			glEnable(GL_TEXTURE_2D);
			gluQuadricNormals(cylinder, GLU_SMOOTH);
			glBindTexture(GL_TEXTURE_2D, 2006);
			gluQuadricTexture(cylinder, GL_TRUE);
			glPushMatrix();
				glTranslatef(x, y, z);
				renderPiece();
			glPopMatrix();  
			glDisable(GL_TEXTURE_2D);
		}
	}

	void applyColour()
	{

	}
};